/**
 * Copyleft (C) 2023-2024 maminjie <canpool@163.com>
 * SPDX-License-Identifier: BSD-3-Clause
 **/
#include "matstyle.h"
#include "matstyle_p.h"
#include "mattheme.h"
#include <QFontDatabase>

QX_MATERIAL_BEGIN_NAMESPACE

/*!
 *  \class MatStylePrivate
 *  \internal
 */

MatStylePrivate::MatStylePrivate()
{
}

MatStylePrivate::~MatStylePrivate()
{
}

void MatStylePrivate::init()
{
    Q_Q(MatStyle);

    QFontDatabase::addApplicationFont(":/fonts/roboto_regular");
    QFontDatabase::addApplicationFont(":/fonts/roboto_medium");
    QFontDatabase::addApplicationFont(":/fonts/roboto_bold");

    q->setTheme(new MatTheme);
}

/*!
 *  \class MatStyle
 *  \internal
 */

void MatStyle::setTheme(MatTheme *theme)
{
    Q_D(MatStyle);

    d->theme = theme;
    theme->setParent(this);
}

QColor MatStyle::themeColor(const QString &key) const
{
    Q_D(const MatStyle);

    Q_ASSERT(d->theme);

    return d->theme->getColor(key);
}

MatStyle::MatStyle() : QCommonStyle()
{
    QX_INIT_PRIVATE(MatStyle)
    d_func()->init();
}

MatStyle::~MatStyle()
{
    QX_FINI_PRIVATE()
}

QX_MATERIAL_END_NAMESPACE
